﻿@using Sausage.Web.Domain
@using System.Text
@using Sausage.Web.DataModel
@using Sausage.Common;
@{
    
	//用于保存天气预警信息
	List<string> weatherWarningModels = new List<string>();

	//用于反应等级类型信息
	List<string> reactionLevelModels = new List<string>();

	//用于反应等级类型信息
	List<string> alarmLevelModels = new List<string>();

	//查询路线信息
	using (SausageEntities entities = new SausageEntities())
	{
		//查询所有角色信息
		foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 11).OrderBy(item => item.ItemName).ToArray())
		{
			//判断是否为空字符
			if (string.IsNullOrEmpty(item.ItemPinYin))
			{
				//转换为字符串
				weatherWarningModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{0}', Value: '{1}' }}", item.ItemName, item.ItemValue));
			}
			else
			{
				//转换为字符串
				weatherWarningModels.Add(string.Format(@"{{ Name: '{1}', PinYin: '{0} {1}', Value: '{2}' }}", item.ItemPinYin, item.ItemName, item.ItemValue));
			}
		}

		//查询所有响应等级信息
		foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 12).OrderBy(item => item.ItemName).ToArray())
		{
			//转换为字符串
			reactionLevelModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{1} {2}' }}", item.ItemName, item.ItemPinYin, item.ItemName));
		}

		//查询所有预警等级信息
		foreach (DictionayItem item in entities.DictionayItem.Where(item => item.DictionayID == 14).OrderBy(item => item.ItemName).ToArray())
		{
			//转换为字符串
			alarmLevelModels.Add(string.Format(@"{{ Name: '{0}', PinYin: '{1} {2}' }}", item.ItemName, item.ItemPinYin, item.ItemName));
		}
	}

	//用于保存养护数据状态
	List<string> maintainDataStates = new List<string>();

	//循环添加状态
	foreach (int item in Enum.GetValues(typeof(MaintainDataStateEnum)))
	{
		//添加状态值
		maintainDataStates.Add(string.Format("{0}:{1}", Enum.GetName(typeof(MaintainDataStateEnum), item), item));
	}

	//用于保存数据状态
	List<string> dataStates = new List<string>();

	//循环添加状态
	foreach (int item in Enum.GetValues(typeof(DataStateEnum)))
	{
		//添加状态值
		dataStates.Add(string.Format("{0}:{1}", Enum.GetName(typeof(DataStateEnum), item), item));
	}

	//用于保存工程数据状态
	List<string> projectDataStates = new List<string>();

	//循环添加状态
	foreach (int item in Enum.GetValues(typeof(ProjectDataStateEnum)))
	{
		//添加状态值
		projectDataStates.Add(string.Format("{0}:{1}", Enum.GetName(typeof(ProjectDataStateEnum), item), item));
	}

	//用于保存工程状态
	List<string> projectStates = new List<string>();

	//循环添加状态
	foreach (int item in Enum.GetValues(typeof(ProjectStateEnum)))
	{
		//添加状态值
		projectStates.Add(string.Format("{0}:{1}", Enum.GetName(typeof(ProjectStateEnum), item), item));
	}

	//生成菜单模型
	List<string> menuModels = MenuHelper.BuildRenderModel();

	//读取附件文件大小限制
	string max_Attachment_Size = System.Configuration.ConfigurationManager.AppSettings["Max_Attachment_Size"];

	//判定是否进行了配置
	if (string.IsNullOrEmpty(max_Attachment_Size))
	{
		//设置为默认值
		max_Attachment_Size = "2 MB";
	}

	//读取附件文件大小限制
	string max_Photo_Size = System.Configuration.ConfigurationManager.AppSettings["Max_Photo_Size"];

	//判定是否进行了配置
	if (string.IsNullOrEmpty(max_Photo_Size))
	{
		//设置为默认值
		max_Photo_Size = "2 MB";
	}

	//读取附件文件类型
	string attachment_File_Types = System.Configuration.ConfigurationManager.AppSettings["Attachment_File_Types"];

	//判定是否进行了配置
	if (string.IsNullOrEmpty(attachment_File_Types))
	{
		//设置为默认值
		attachment_File_Types = "*.doc;*.docx;*.xls;*.xlsx:*.dwg:*.pdf";
	}

	//读取附件文件大小限制
	string photo_File_Types = System.Configuration.ConfigurationManager.AppSettings["Photo_File_Types"];

	//判定是否进行了配置
	if (string.IsNullOrEmpty(photo_File_Types))
	{
		//设置为默认值
		photo_File_Types = "*.jpg;*.jpeg";
	}

	//获得当期动作地址
	string actionUrl = Sausage.Web.Code.UIHelper.GetCurrentActionUrl(this);
}
<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<meta http-equiv="Content-Script-Type" content="text/javascript" />
	<meta http-equiv="Content-Style-Type" content="text/css" />
	<meta name="keywords" content="" />
	<meta name="description" content="" />
	<title>@ViewBag.Title</title>
	<link type="text/css" rel="stylesheet" href="@Url.Content("~/Content/Styles/Layout.css")" media="all">
	<link type="text/css" rel="stylesheet" href="@Url.Content("~/Content/Styles/Site.css")" media="all">
	<link href="@Url.Content("~/Scripts/ExtJS/resources/css/ext-all-gray.css")" rel="stylesheet" type="text/css" />
	@RenderSection("HeadCssLink", false)
	<script src="@Url.Content("~/Scripts/JQuery/jquery-1.6.4.min.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/ExtJS/bootstrap.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/SWFUpload/swfupload.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/SWFUpload/plugins/swfupload.swfobject.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/SWFUpload/plugins/swfupload.cookies.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/SWFUpload/plugins/swfupload.queue.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Content/SWFUpload/plugins/swfupload.speed.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/common.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/fileupload.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/Sausage/Main/Index.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/Sausage/Shared/Menu.js")" type="text/javascript"></script>
	<script src="@Url.Content("~/Scripts/Sausage/Shared/Emergency.js")" type="text/javascript"></script>
	@RenderSection("HeadScriptLink", false)
	<!--[if lt IE 9]>
      <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<script type="text/javascript" language="javascript">

        //用于保存天气预警信息
        var master_weatherwarning =
        [
            @Html.Raw(System.String.Join(",", weatherWarningModels))
        ];

        //用于保存响应等级信息
        var master_reaction_level =
        [
            @Html.Raw(System.String.Join(",", reactionLevelModels))
        ];

		//用于保存预警等级信息
        var master_alarm_level =
        [
            @Html.Raw(System.String.Join(",", alarmLevelModels))
        ];

        //生成菜单模型
        var model_menus =
        [
            @Html.Raw(System.String.Join(",", menuModels))
        ];

        //渲染表格只读复选框
        function renderGridReadonlyCheckBox( val )
        {
            //判断是否选中
            if ( val )
            {
                return '<img src="@Url.Content("~/Content/Images/checkbox_checked.png")" style=" width:13px; height:13px;"/>';
            }
            else
            {
                return '<img src="@Url.Content("~/Content/Images/checkbox_unchecked.png")" style=" width:13px; height:13px;"/>';
            }
        }

        //动作路径根路径
        var ActionUrlRoot = '@Url.Action("Index")';
        //当前动作路径
        var _Current_ActionUrl = '@Html.Raw(actionUrl)'
        //拼音转换的查询地址
        var PinYinUrl = '@Url.Content("~/PinYin/Convert")';
        //主机地址
        var HostUrl = '';

        //数据状态
        var DataStateEnum =
        {
            @Html.Raw(System.String.Join(",", dataStates))
        };

        //养护数据状态枚举
        var MaintainDataStateEnum =
        {
            @Html.Raw(System.String.Join(",", maintainDataStates))
        };
        //工程数据状态枚举
        var ProjectDataStateEnum =
        {
            @Html.Raw(System.String.Join(",", projectDataStates))
        };

        //工程状态
        var ProjectStateEnum =
        {
            @Html.Raw(System.String.Join(",", projectStates))
        };

        //当前用户分类
        var current_user_category = @Html.Raw(Helper.CurrentPrincipal.User.Organization.Category.ToString());
        //当前用户名称
        var current_user_name = '@Html.Raw(Helper.CurrentPrincipal.User.UserName)';

        //上传Flash的地址
        var upload_flash_url = '@Url.Content("~/Content/SWFUpload/Flash/swfupload.swf")';
        //上传按钮图片地址
        var upload_button_url = '@Url.Content("~/Content/Images/ButtonUpload.png")';
        //表格删除按钮图片地址
        var grid_delete_image_url =  '@Url.Content("~/Content/Images/grid_icon_delete.png")';
        //附件尺寸限制
        var attachment_file_size_limit = '@Html.Raw(max_Attachment_Size)';
        //附件尺寸限制
        var attachment_file_size_limit_tip = '不超过 @Html.Raw(max_Attachment_Size)';
        //附件文件类型
        var attachment_file_types = '@Html.Raw(attachment_File_Types)';
        //图片文件类型说明
        var attachment_file_types_description = '附件文件（@Html.Raw(attachment_File_Types)）';
        //图片尺寸限制
        var photo_file_size_limit =  '@Html.Raw(max_Photo_Size)';
        //图片尺寸限制
        var photo_file_size_limit_tip = '不超过 @Html.Raw(max_Photo_Size)';
        //图片文件类型
        var photo_file_types = '@Html.Raw(photo_File_Types)';
        //图片文件类型说明
        var photo_file_types_description = '图片文件（@Html.Raw(photo_File_Types)）';
	</script>
</head>
<body>
	<div>
		<header>
            <a href="@Url.Action("Index", "Home")" >
                <div id="logo">&nbsp;</div>
            </a>
			<div style="float:left;  overflow-y:hidden; overflow-x:visible">
			   <div id="emergency_reaction_statusbar" title="应急反应信息" >
                   <div>
                   @if (Helper.CurrentPrincipal.IsInRole("ReactionPoster"))
				   {
                       <a href="javascript:void(0);"  onclick="javascript:return AppendEmergencyReaction();">
                       <!--<img id="emergency_image" src="" alt="天气预警" />-->
                       <span id="emergency_text"></span>
                       </a>
				   }
				   else
				   {
                       <!--<img id="emergency_image" src="" alt="天气预警" />-->
                       <span id="emergency_text"></span>
				   }
                   </div>
               </div>
			 </div>
            <div style="float:right;  overflow-y:hidden; overflow-x:visible">
             
               <div id="login_menu">
                    <ul>
                        <li>@Helper.CurrentPrincipal.User.UserName </li>
                        @if (Helper.CurrentPrincipal.IsInRole("ReactionPoster") || Helper.CurrentPrincipal.IsInRole("SystemAdmin"))
						{
                            @Html.Raw("<li>|</li><li><a href=\"javascript:void(0);\" onclick=\"javascript:return AppendEmergencyReaction();\">发布应急反应</a></li>")
						}
                        <li>|</li><li><a href="@Url.Action("ChangePassword", "Login")">修改密码</a></li>
                        <li>|</li><li><a href="@Url.Action("Logout", "Home")">退出</a></li>
                    </ul>
                </div>
            </div >
        </header>
		<div id="main_content" class="Main_Content">
			<div id="topBarPlace">
			</div>
			<div id="side_menu" class="Side_Menu">
			</div>
			<div id="body_content" class="Body_Content">
				@RenderBody()
				<div id="swf_upload">
					<span id="btnSelectFile"></span>
				</div>
			</div>
			<div id="footer_content" class="Footer_Content">
				<footer>
                    <ul>
                        <li>天水公路总段 &copy;  版权所有.</li>
                    </ul>
                </footer>
			</div>
		</div>
	</div>
</body>
</html>
